﻿using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VisionCloud.Core.Model.Ms;
using VisionCloud.Domain.DtoModel.Ms;
using VisionCloud.Domain.Repository.Interface.Ms;

namespace VisionCloud.Domain.Repository.Implement.Ms
{
    public class MsSQualityAnalysisRepository : BaseRepository<MsSQualityAnalysis>, IMsSQualityAnalysisRepository
    {
        /// <summary>
        /// 根据条件取质量分析表数据
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public async Task<List<MsSQualityAnalysis>> GetListOfData(MsSQualityAnalysisCondition condition)
        {
            var list = await (
                from up in Db.MsSQualityAnalysis
                join p in Db.MsProjects on up.ProjectGuid equals p.ProjectId
                where !p.IsDeleted && p.Status == MsProject.ProjectStatus.启用
                                   && up.ProjectGuid == condition.ProjectGuid
                                   && up.CompanyGuid == condition.CompanyGuid
                select up
            ).AsNoTracking().ToListAsync().ConfigureAwait(false);
            return list;
        }
    }
}